package practice04;

import java.util.Iterator;
import java.util.LinkedList;

/**
 * @author Administrator
 * @version V1.0
 * @ProjectName:IntelliJ IDEA
 * @PackageName: practice04
 * @ClassName: QQ
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @date 2019/12/17 19:01
 * @Copyright 大牛版板所有
 */
public class QQ {
    public static void main(String[] args) {
        LinkedList<String> list = new LinkedList<>();
        String[] strs = {"12345","67891","12347809933","98765432102","67891","12347809933"};
        for (int i = 0; i < strs.length; i++) {
            list.add(strs[i]);
        }

        // 去重
        LinkedList<String> list1 = new LinkedList<>();
        for (int i = 0; i <list.size() ; i++) {
            for (int j = i+1; j < list.size(); j++) {
                if (list.get(i).equals(list.get(j))){
                    list1.add(list.get(i));
                }
            }
        }
        for (int i = 0; i < list1.size(); i++) {
            list.remove(list1.get(i));
        }

        // 遍历list
        System.out.println("===============Iterator遍历==================");
        Iterator<String> iter = list.iterator();
        while (iter.hasNext()){
            String s = iter.next();
            System.out.print(s+"  ");
        }

        System.out.println("\n\n==============foreach遍历====================");
        for (String s:list) {
            System.out.print(s+"  ");
        }
    }
}
